package com.dsy.xiangcun_index.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dsy.tools.common.utils.QueryObj;
import com.dsy.tools.entity.TbTou;
import com.dsy.xiangcun_index.mapper.TbTouMapper;
import com.dsy.xiangcun_index.service.ITbTouService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dsy
 * @since 2019-12-29
 */
@Service
public class TbTouServiceImpl extends ServiceImpl<TbTouMapper, TbTou> implements ITbTouService {

    @Autowired
    TbTouMapper touMapper;

    /**
     * 分页查询
     * @param page 第几页
     * @param limit 获取几条数据
     * @return
     */
    @Override
    public IPage<TbTou> getAllTou(long page, long limit, Wrapper<QueryObj> wrapper){
        IPage<TbTou> touPage = touMapper.selectTouPage(new Page<>(page,limit),wrapper);
        return touPage;
    }

    @Override
    public TbTou getByUserName(@Param("username") String username) {
        TbTou tou=touMapper.getByUserName(username);
        return tou;
    }

    @Override
    public IPage<TbTou> getActJoinById(Page<TbTou> page, Integer acId) {
        IPage<TbTou> touPage = touMapper.selectActJoinById(page,acId);
        return touPage;
    }

    @Override
    public TbTou getTouById(Integer userId) {
        return touMapper.getTouById(userId);
    }

    @Override
    public TbTou getMyById(Integer userId) {
        return touMapper.getTouById(userId);
    }

}
